<?php
# this is file with all interface functions necessary to create register page

# this is function that will return final data for register page
function i_search_group(){
	$html = '';
	$search_value = '';
	if(isset($_GET['group'])) $search_value = $_GET['group'];
	# search field
	$html .= '<div class="wrapper">'.
				'<div class ="header"></div>'.
				'<div class="mainPage" >'.
					'<h2  style="margin-left:350px;"> Search Groups</h2>'.
					'<p>&nbsp;</p>'.
					'<form id="form2" name="form2" method="post" action="php/core/Search_group/p_search_group.php">';
	# display error messages
	if(has_errors()){
		$html .= '<br/><br/>';
		$err = i_get_msg_err();
		$ci = count($err);
		for($i=0; $i<$ci; $i++){
			$html .= '<div align="center" id="error_msg">' . $err[$i] . '</div>';
		}
	}
	# display info messages
	if(has_inf_msg()){
		$inf = i_get_msg_inf();
		$ci = count($inf);
		for($i=0; $i<$ci; $i++){
			$html .= '<div id="msg_inf">' . $inf[$i] . '</div>';
		}
	}
	$html .=			'<table border="0"  style="margin-left:350px;">'.
							'<tr>'.
								'<td width="170">'.
									'<input type="text" name="search_text" value="'.$search_value.'" />'.
								'</td>'.
								'<td width="141">'.
									'<input type="submit" name="search_button" value="Search" style="width:70px"/>'.
								'</td>'.
							'</tr>'.
						'</table>'.
					'</form>'.
					'<p>&nbsp;</p>';
	# result table
	if($search_value != ''){
		$groups = c_group_list($search_value);
		if(!empty($groups)){
			$html .='<table border=" " style="margin-left:250px;">'.
						'<tr>'.
							'<th width="197" scope="col"><div align="center"><u>Group</u></div></th>'.
							'<th width="197" scope="col"><u>Group master</u></th>'.
							'<td width="62" scope="col"></td>'.
						'</tr>';
			$ci = sizeof($groups);
			for($i=0;$i<$ci;$i++){
				$group = $groups[$i];
				$html .='<tr>'.
							'<td><div align="center">'.$group['group_name'].'</div></td>'.
							'<td>'.$group['master_name'].'</td>'.
							'<td><a href="php/core/Search_group/p_search_group_join.php?group_id='.$group['group_id'].'">Join</a></td>'.
						'</tr>';
			}
			$html .= 	''. // to keep alignment
					'</table>';
		}
		else{
			$html .='<div style="margin-left:200px; color:red;" align="center">Such group not found</div>';
		}
	}
	$html .=	'</div>'.
				'<div class="clear">&nbsp;</div>'.
			'</div>';
	return $html;
} // i_search()
?>






	 